package com.controller;

import com.dto.EditGroupVerifyMessageDTO;
import com.entity.GroupVerifyMessage;
import com.github.pagehelper.PageInfo;
import com.service.GroupVerifyMessageService;
import com.vo.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 群验证控制器
 *
 * @author lbb
 * @version 1.0
 * @date 2020.3.22
 */

@RestController
@RequestMapping("/api")
public class GroupVerifyMessageController {
	
	@Autowired
	private GroupVerifyMessageService groupVerifyMessageService;
	
	/**
	 * 发送群请求
	 *
	 * @param groupVerifyMessage 请求信息
	 * @return
	 */
	@PostMapping("/groupVerifyMessage/add")
	public ResponseVO addGroupVerifyMessage(@RequestBody GroupVerifyMessage groupVerifyMessage) {
		return new ResponseVO("200", null, groupVerifyMessageService.addGroupVerifyMessage(groupVerifyMessage));
	}
	
	/**
	 * 根据群ID获取到全部的群验证信息
	 * @param toGroupId 群ID
	 * @return
	 */
	@GetMapping("/groupVerifyMessage/getByToGroupId")
	public ResponseVO getByToGroupIdAllGroupVerifyMessage(Integer pageNum,Integer pageSize,Integer toGroupId) {
		PageInfo pageInfo = new PageInfo(groupVerifyMessageService.getByToGroupIdAllGroupVerifyMessage(pageNum,pageSize,toGroupId));
		return new ResponseVO("200", null, pageInfo);
	}

	/**
	 * 根据用户ID获取到全部的群验证信息
	 * @param fromUserId 发请求的用户ID
	 * @return
	 */
	@GetMapping("/groupVerifyMessage/getByToUserId")
	public ResponseVO getByToUserIdAllGroupVerifyMessage(Integer pageNum,Integer pageSize,Integer fromUserId) {
		PageInfo pageInfo = new PageInfo(groupVerifyMessageService.getByToUserIdAllGroupVerifyMessage(pageNum, pageSize, fromUserId));
		return new ResponseVO("200", null, pageInfo);
	}
	
	/**
	 * 是否同意
	 * 同意需要添加成员信息，拒绝则无需添加
	 * @param groupVerifyMessage
	 * @return
	 */
	@PostMapping("/groupVerifyMessage/editStatus")
	public ResponseVO editStatus(@RequestBody GroupVerifyMessage groupVerifyMessage) {
		return new ResponseVO("200", null, groupVerifyMessageService.editStatus(groupVerifyMessage));
	}
}
